import instance from "./axios";
// 登录
export let dlapi = (data: { account: string; password: string }) => {
  return instance({
    method: "post",
    url: "/api/login",
    data: {
      ...data,
    },
  });
};
// 列表
export let lbapi = (data: {
  page: number;
  pageSize: number;
  keyword?: string;
  tag?: string;
}) => {
  return instance({
    method: "get",
    url: "/api/article/list",
    params: {
      ...data,
    },
  });
};
// 删除列表
export let delapi = ( id:number) => {
  return instance({
    method: "DELETE",
    url: `/api/article/${id}`,
    params: {
      article:id
    },
  });
};
// 新增
export let addapi = (data: {
title:string,//文章标题
content:string,//文章内容
tagList:string[],//标签  array[string]
categoryList:string[],//分类  array[string]

}) => {
  return instance({
    method: "post",
    url: "/api/article",
    data: {
      ...data,
      authorId:47529555//用户id 暂时写死47529555 登陆成功后返回的用
    },
  });
};
// 修改列表
export let editapi = ( id:number,data:{title:string,content:string,tagList:[],categoryList:[]}) => {
  return instance({
    method: "PUT",
    url: `/api/article/${id}`,
    params: {
      data:{
        ...data
      }
    },
  });
};